package asionreachel.cn.smarthomedemo.base;

import android.app.Activity;
import android.content.Intent;

import asionreachel.cn.smarthomedemo.device.cdm1.Device_CDM1Activity;
import familyclient.android.common.JToolFunc;
import familyclient.android.device.cd01.JDevice_CD01Interface;
import familyclient.android.device.cdm1.JDevice_CDM1Interface;
import familyclient.android.device.cl01.JDevice_CL01Interface;
import familyclient.android.device.of02.JDevice_OF02Interface;
import familyclient.android.device.of03.JDevice_OF03Interface;
import familyclient.android.device.rc01.JDevice_RC01Interface;
import familyclient.android.device.rc02.JDevice_RC02Interface;
import familyclient.android.device.rg01.JDevice_RG01Interface;
import familyclient.android.device.shb2.JDevice_SHB2Interface;

public class BaseDevice
{
    public static boolean ResetDevice( String a_strDeviceID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().ResetDevice( a_strDeviceID );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean SetFamily( String a_strDeviceID, String a_strFamilyID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().SetFamily( a_strDeviceID, a_strFamilyID );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean SetDeviceName( String a_strDeviceID, String a_strDeviceName )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().SetDeviceName( a_strDeviceID, a_strDeviceName );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean GetDeviceInfo( String a_strDeviceID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().GetDeviceInfo( a_strDeviceID );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean GetDeviceInfoList( String a_strDeviceType )
    {
        switch ( a_strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().GetDeviceInfoList();
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean SetShareInfo( String a_strDeviceID, String a_strShareFamilyID, int a_iShareValue )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().SetShareInfo( a_strDeviceID, a_strShareFamilyID, a_iShareValue );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean GetShareInfoList( String a_strDeviceID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().GetShareInfoList( a_strDeviceID );
                break;
            default:
                return false;
        }
        return true;
    }

    public static boolean ClearAllShareInfo( String a_strDeviceID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        if( null == strDeviceType || 0 == strDeviceType.length() )
            return false;

        switch ( strDeviceType )
        {
            case ConstantDefinition.CDM1:
                JDevice_CDM1Interface.GetInstance().ClearAllShareInfo( a_strDeviceID );
                break;
            default:
                return false;
        }
        return true;
    }

    public static void GetAllDeviceInfoList()
    {
        JDevice_CD01Interface.GetInstance().GetDeviceInfoList();
        JDevice_CL01Interface.GetInstance().GetDeviceInfoList();
        JDevice_OF02Interface.GetInstance().GetDeviceInfoList();
        JDevice_OF03Interface.GetInstance().GetDeviceInfoList();
        JDevice_RC01Interface.GetInstance().GetDeviceInfoList();
        JDevice_RC02Interface.GetInstance().GetDeviceInfoList();
        JDevice_CDM1Interface.GetInstance().GetDeviceInfoList();
        JDevice_SHB2Interface.GetInstance().GetDeviceInfoList();
        JDevice_RG01Interface.GetInstance().GetDeviceInfoList();
    }

    public static Intent GetIntent( Activity tpActivity , String a_strDeviceID )
    {
        String strDeviceType = JToolFunc.DeviceIDToDeviceType( a_strDeviceID );
        Intent intent = null;
        if( null != strDeviceType && strDeviceType.length() > 0 )
        {
            switch ( strDeviceType )
            {
                case ConstantDefinition.CDM1:
                    intent = new Intent( tpActivity , Device_CDM1Activity.class );
                    break;
                default:
                    return null;
            }
        }
        if( null != intent )
            intent.putExtra( "DeviceID", a_strDeviceID );
        return intent;
    }
}
